<template xmlns="">
  <el-container  class="appData">
    <el-header>
      <TopPanel class="headerFaceplate"></TopPanel>
    </el-header>
    <el-container>
      <el-aside width="200px">
        <el-menu
            default-active="2"
            class="el-menu-vertical-demo"
        >
          <el-menu-item @click="changePageFun('zhongziPage')" index="1">
            <span>小麦种子录入</span>
          </el-menu-item>
          <el-menu-item @click="changePageFun('feilaioPage')" index="2">
            <span>小麦肥料录入</span>
          </el-menu-item>
        </el-menu>
      </el-aside>
      <el-main class="formBase" >
        <el-container v-if="thisPage === 'zhongziPage'" >
          <el-header >
            <el-button @click="zhongziDialog = true" :icon="Plus">添加</el-button>
<!--            <el-button :icon="Minus">删除</el-button>-->
          </el-header>
          <el-main>
            <el-table :data="zhongziData" border style="width: 100%">
              <el-table-column type="selection" width="55" />
              <el-table-column prop="id" label="ID" width="50" />
              <el-table-column prop="name" label="小麦品种" width="180" />
              <el-table-column prop="count" label="数量（吨）" />
              <el-table-column prop="manufacturers" label="生产厂家" />
              <el-table-column prop="administrator" label="管理者" />
              <el-table-column prop="date" label="添加日期" />

              <el-table-column prop="date" label="添加日期" />
              <el-table-column fixed="right" label="操作" width="120">
                <template #default>
                  <el-button link type="primary" size="small" >修改</el-button>
                  <el-button link type="primary" size="small">删除</el-button>
                </template>
              </el-table-column>
            </el-table>
            <el-dialog
                class="txdt_imgDialog"
                :show-close="false"
                v-model="zhongziDialog"
                title=""
            >
<!--                style="width: 1200px"-->
<!--                :destroy-on-close="true"-->
<!--              style="max-width: 600px"-->
              <template #title>添加种子信息</template>
              <el-form :model="zhogziForm" label-width="auto" >
                <el-form-item label="小麦品种">
                  <el-input v-model="zhogziForm.name" />
                </el-form-item>
                <el-form-item label="数量(吨)">
                  <el-input-number v-model="zhogziForm.count" />
                </el-form-item>
                <el-form-item label="生产厂家">
                  <el-select v-model="zhogziForm.manufacturers" placeholder="请选择">
                    <el-option label="上海厂家" value="上海厂家" />
                    <el-option label="北京厂家" value="北京厂家" />
                  </el-select>
                </el-form-item>
                <el-form-item label="管理者">
                  <el-input v-model="zhogziForm.administrator" />
                </el-form-item>
                <el-form-item>
                  <el-button type="primary" @click="zhongziDialog = false">提交</el-button>
                  <el-button  @click="zhongziDialog = false">取消</el-button>
                </el-form-item>
              </el-form>
            </el-dialog>
          </el-main>
        </el-container>
        <el-container v-if="thisPage === 'feilaioPage'" >
          <el-header >
            <el-button :icon="Plus" @click="feiliaoDialog = true">添加</el-button>
<!--            <el-button :icon="Minus">删除</el-button>-->
          </el-header>
          <el-main>
            <el-table :data="feiliaoData" border style="width: 100%">
              <el-table-column type="selection" width="55" />
              <el-table-column prop="id" label="ID" width="50" />
              <el-table-column prop="name" label="肥料品牌" width="180" />
              <el-table-column prop="content" label="肥料含量" />
              <el-table-column prop="count" label="数量（吨）" />
              <el-table-column prop="manufacturers" label="生产厂家" />
              <el-table-column prop="administrator" label="管理者" />
              <el-table-column prop="date" label="添加日期" />
              <el-table-column fixed="right" label="操作" width="120">
                <template #default>
                  <el-button link type="primary" size="small" >修改</el-button>
                  <el-button link type="primary" size="small">删除</el-button>
                </template>
              </el-table-column>
            </el-table>
            <el-dialog
                class="txdt_imgDialog"
                :show-close="false"
                v-model="feiliaoDialog"
                title=""
            >
              <template #title>添加肥料信息</template>
              <el-form :model="feiliaoForm" label-width="auto" >
                <el-form-item label="小麦品种">
                  <el-input v-model="feiliaoForm.name" />
                </el-form-item>
                <el-form-item label="肥料含量%">
                  <el-input-number v-model="feiliaoForm.content" />
                </el-form-item>
                <el-form-item label="数量(吨)">
                  <el-input-number v-model="feiliaoForm.count" />
                </el-form-item>
                <el-form-item label="生产厂家">
                  <el-select v-model="feiliaoForm.manufacturers" placeholder="请选择">
                    <el-option label="上海厂家" value="上海厂家" />
                    <el-option label="北京厂家" value="北京厂家" />
                  </el-select>
                </el-form-item>
                <el-form-item label="管理者">
                  <el-input v-model="feiliaoForm.administrator" />
                </el-form-item>
                <el-form-item>
                  <el-button type="primary" @click="feiliaoDialog = false">提交</el-button>
                  <el-button  @click="feiliaoDialog = false">取消</el-button>
                </el-form-item>
              </el-form>
            </el-dialog>
          </el-main>
        </el-container>
      </el-main>
    </el-container>
  </el-container>
</template>

<script  >
import {onMounted, reactive, ref, toRefs} from "vue";
import TopPanel from "@/components/header/topPanel.vue";
import {
  Check,
  Delete,
  Edit,
  Message,
  Search,
  Minus,
  Plus
} from '@element-plus/icons-vue'

export default {
  name: "Home",
  components: {TopPanel},
  setup() {
    let state = reactive({
      thisPage:"zhongziPage",
      zhongziData: [
        {id:1,name:'小麦种子1',count:101,manufacturers:'种子公司',administrator:'张三',date:'2021-01-01'},
        {id:2,name:'小麦种子2',count:102,manufacturers:'种子公司',administrator:'王小虎',date:'2016-05-02'},
        {id:3,name:'小麦种子3',count:103,manufacturers:'种子公司',administrator:'Tom',date:'2016-05-02'},

      ],
      feiliaoData: [
        {id:1,name:'肥料品牌1',content:'20%',count:101,manufacturers:'种子公司',administrator:'张三',date:'2021-01-01'},
        {id:2,name:'肥料品牌2',content:'30%',count:102,manufacturers:'种子公司',administrator:'王小虎',date:'2021-05-02'},
        {id:3,name:'肥料品牌3',content:'40%',count:103,manufacturers:'种子公司',administrator:'Tom',date:'2021-01-01'},
        {id:4,name:'肥料品牌4',content:'50%',count:104,manufacturers:'种子公司',administrator:'李四',date:'2021-10-01'},
      ],
      zhongziDialog:false,
      feiliaoDialog:false,
      zhogziForm:{
        name: '',
        count: 10,
        manufacturers: '',
        administrator: '',
        date: ''
      },
      feiliaoForm:{
        name: '',
        content: 0.25,
        count: 10,
        manufacturers: '',
        administrator: '',
        date: ''
      }
    })
    // 地图改色
    onMounted(()=>{

    });
    function changePageFun(pageKey){
      state.thisPage = pageKey
    }
    return{
      ...toRefs(state),
      changePageFun,
      Edit,
      Plus,
      Minus,
    }
  },
};
</script>

<style lang="scss" scoped>
.appData{
  width: 100%;
  height: 100%;
  .headerFaceplate{
    width: 100%;
    left: 0;
    top: 0;
    height: 65px;
  }
  .formBase{
    --el-main-padding:0;
    border: 0;
    padding-top: 5px;
    width: 100%;
    height: 100%;
    .el-header{
      display: flex;
      flex-direction: row;
      align-items: center;
    }
  }
}
</style>
